<!DOCTYPE html><html lang="zh-CN" data-theme="dark"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>webAPP 美食项目 | 北城韩雨</title><meta name="keywords" content="React webAPP"><meta name="author" content="北城韩雨"><meta name="copyright" content="北城韩雨"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#0d0d0d"><meta name="description" content="React">
<meta property="og:type" content="article">
<meta property="og:title" content="webAPP 美食项目">
<meta property="og:url" content="http://example.com/2019/03/24/%E7%A7%BB%E5%8A%A8%E7%AB%AF%E7%BE%8E%E9%A3%9FwebAPP-react/index.html">
<meta property="og:site_name" content="北城韩雨">
<meta property="og:description" content="React">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcz-video-photo.oss-cn-beijing.aliyuncs.com%2F20191017%2F4cfc341591d242327b67e9ceb6953612_00002.jpg&refer=http%3A%2F%2Fcz-video-photo.oss-cn-beijing.aliyuncs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1629530702&t=80943e12d5239f63beafd6d1c540855f">
<meta property="article:published_time" content="2019-03-23T16:00:00.000Z">
<meta property="article:modified_time" content="2019-06-02T16:00:00.000Z">
<meta property="article:author" content="北城韩雨">
<meta property="article:tag" content="React">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcz-video-photo.oss-cn-beijing.aliyuncs.com%2F20191017%2F4cfc341591d242327b67e9ceb6953612_00002.jpg&refer=http%3A%2F%2Fcz-video-photo.oss-cn-beijing.aliyuncs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1629530702&t=80943e12d5239f63beafd6d1c540855f"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="http://example.com/2019/03/24/%E7%A7%BB%E5%8A%A8%E7%AB%AF%E7%BE%8E%E9%A3%9FwebAPP-react/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'mediumZoom',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'webAPP 美食项目',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2019-06-03 00:00:00'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/css/custom.css"  media="defer" onload="this.media='all'"><link rel="stylesheet" href="/css/coin.css"  media="defer" onload="this.media='all'"><link rel="stylesheet" href="/css/liuxing.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/l-lin/font-awesome-animation/dist/font-awesome-animation.min.css"  media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper/swiper-bundle.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zhheo/JS-Heo@main/bb/showbb_in_index.css"><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" media="print" onload="this.media='screen'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/l-lin/font-awesome-animation/dist/font-awesome-animation.min.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hexo-butterfly-tag-plugins-plus/lib/tag_plugins.min.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --><meta name="generator" content="Hexo 5.3.0"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/my.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">65</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">23</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">21</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/"><i class="fa-fw fas fa-home faa-tada"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/shuoshuo/"><i class="fa-fw fas fa-archive faa-tada"></i><span> 叨逼叨</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/tags/"><i class="fa-fw fas fa-tags faa-tada"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/categories/"><i class="fa-fw fas fa-folder-open faa-tada"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/link/"><i class="fa-fw fas fa-link faa-tada"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/comments/"><svg class="icon faa-tada" aria-hidden="true"><use xlink:href="#icon-message"></use></svg><span> 留言板</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/about/"><i class="fa-fw fas fa-heart faa-tada"></i><span> 个人简介</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcz-video-photo.oss-cn-beijing.aliyuncs.com%2F20191017%2F4cfc341591d242327b67e9ceb6953612_00002.jpg&amp;refer=http%3A%2F%2Fcz-video-photo.oss-cn-beijing.aliyuncs.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530702&amp;t=80943e12d5239f63beafd6d1c540855f')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">北城韩雨</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/"><i class="fa-fw fas fa-home faa-tada"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/shuoshuo/"><i class="fa-fw fas fa-archive faa-tada"></i><span> 叨逼叨</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/tags/"><i class="fa-fw fas fa-tags faa-tada"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/categories/"><i class="fa-fw fas fa-folder-open faa-tada"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/link/"><i class="fa-fw fas fa-link faa-tada"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/comments/"><svg class="icon faa-tada" aria-hidden="true"><use xlink:href="#icon-message"></use></svg><span> 留言板</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/about/"><i class="fa-fw fas fa-heart faa-tada"></i><span> 个人简介</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">webAPP 美食项目</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2019-03-23T16:00:00.000Z" title="发表于 2019-03-24 00:00:00">2019-03-24</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2019-06-02T16:00:00.000Z" title="更新于 2019-06-03 00:00:00">2019-06-03</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/">项目实战</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">7k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>31分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="webAPP 美食项目"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h2 id="项目概述"><a href="#项目概述" class="headerlink" title="项目概述"></a>项目概述</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>主要是用react 一系列技术栈 搭建的webAPP 美食项目</span><br><span class="line"><span class="number">2.</span>主要技术栈 有react react-redux react-router-dom redux redux-saga ui 是 手机的 antd</span><br><span class="line"><span class="number">3.</span>数据模拟 使用的json-server 数据是后写的 </span><br><span class="line"><span class="number">3.</span>主要功能演示如下</span><br></pre></td></tr></table></figure>
<p><img src="7.gif" alt=""></p>
<h2 id="项目功能"><a href="#项目功能" class="headerlink" title="项目功能"></a>项目功能</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>底部的tab 菜单 使用配置文件的方式去写的</span><br><span class="line"><span class="number">2.</span>头部 公共的header 我们点击tab的每一项目的时候 头部的标题都会跟着改变 但是点击到分类的时候 这个头部又和其他菜单的不一样</span><br><span class="line"><span class="number">3.</span>页面的请求有些事公共数据 异步请求这里 使用的redux-saga 和 redux 去实现的</span><br><span class="line"><span class="number">4.</span>当点击分类的时候 头部的是显示分类和食材 并且点击之后 显示不同的页面 这个是用路由去写的</span><br><span class="line"><span class="number">5.</span>当点击更多的时候 是否显示地图 点击切换之后 可以看见 tab的美食地图菜单不见了 实现了动态的切换</span><br></pre></td></tr></table></figure>
<h2 id="功能逻辑极代码"><a href="#功能逻辑极代码" class="headerlink" title="功能逻辑极代码"></a>功能逻辑极代码</h2><h3 id="底部tab菜单"><a href="#底部tab菜单" class="headerlink" title="底部tab菜单"></a>底部tab菜单</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>我们使用的ant的UI组件库 它题库了tab的使用</span><br><span class="line"><span class="number">2.</span>这我们采用配置文件的形式 去我们的底部菜单 这样也方便我们更改</span><br><span class="line"><span class="number">3.</span>每次点击的时候 我们都会想reducer里发送action状态 并把当前点击的那一项传送过去 </span><br><span class="line"><span class="number">4.</span>然后我们公共的头部 去reducer里 取出来 从而做到 你切换的时候 我们的头部显示对应的功能</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//tabItme.js 配置菜单的文件 在 tab组件中使用</span></span><br><span class="line"><span class="comment">//底部对应的而选中 和没有选中的图片</span></span><br><span class="line"><span class="keyword">import</span> meishi <span class="keyword">from</span> <span class="string">&#x27;../../../asset/meishi.png&#x27;</span></span><br><span class="line"><span class="keyword">import</span> meishi_1 <span class="keyword">from</span> <span class="string">&#x27;../../../asset/meishi_1.png&#x27;</span></span><br><span class="line"><span class="keyword">import</span> category <span class="keyword">from</span> <span class="string">&#x27;../../../asset/category.png&#x27;</span></span><br><span class="line"><span class="keyword">import</span> class1 <span class="keyword">from</span> <span class="string">&#x27;../../../asset/class.png&#x27;</span></span><br><span class="line"><span class="keyword">import</span> map <span class="keyword">from</span> <span class="string">&#x27;../../../asset/map.png&#x27;</span></span><br><span class="line"><span class="keyword">import</span> map1 <span class="keyword">from</span> <span class="string">&#x27;../../../asset/map1.png&#x27;</span></span><br><span class="line"><span class="keyword">import</span> gengduo <span class="keyword">from</span> <span class="string">&#x27;../../../asset/gengduo.png&#x27;</span></span><br><span class="line"><span class="keyword">import</span> gengduo_1 <span class="keyword">from</span> <span class="string">&#x27;../../../asset/gengduo_1.png&#x27;</span></span><br><span class="line"><span class="comment">//对应四个点击的页面组件</span></span><br><span class="line"><span class="keyword">import</span> Home <span class="keyword">from</span> <span class="string">&#x27;../../pages/home/Home.jsx&#x27;</span></span><br><span class="line"><span class="keyword">import</span> Fication <span class="keyword">from</span> <span class="string">&#x27;@/views/pages/classPage/fication&#x27;</span></span><br><span class="line"><span class="keyword">import</span> FoodMap <span class="keyword">from</span> <span class="string">&#x27;@/views/pages/map/map&#x27;</span></span><br><span class="line"><span class="keyword">import</span> More <span class="keyword">from</span> <span class="string">&#x27;@/views/pages/more/More&#x27;</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">const</span> icon = <span class="function">() =&gt;</span> &#123;</span><br><span class="line">   <span class="keyword">return</span> [</span><br><span class="line">      &#123;	  <span class="comment">//底部菜单的中文显示 每次点击的时候需要把它传送给reducer 然后在公共的头部在从reducer中获取</span></span><br><span class="line">          title:<span class="string">&quot;菜谱大全&quot;</span>,</span><br><span class="line">          <span class="comment">//默认显示的图标</span></span><br><span class="line">          <span class="keyword">default</span>:meishi,</span><br><span class="line">          <span class="comment">//选中情况下选中的突变</span></span><br><span class="line">          active:meishi_1,</span><br><span class="line">          content:<span class="string">&quot;菜谱大全页面&quot;</span>,</span><br><span class="line">          <span class="comment">//当点击的时候对应要渲染的组件</span></span><br><span class="line">          renderContent: <span class="function">() =&gt;</span> &#123;</span><br><span class="line">          <span class="keyword">return</span> (<span class="xml"><span class="tag">&lt;<span class="name">Home</span>/&gt;</span></span>)</span><br><span class="line">      &#125;&#125;,</span><br><span class="line">      &#123;<span class="attr">title</span>:<span class="string">&quot;分类&quot;</span>,<span class="attr">default</span>:category,<span class="attr">active</span>:class1,<span class="attr">content</span>:<span class="string">&quot;分类页面&quot;</span>,<span class="attr">renderContent</span>: <span class="function">() =&gt;</span> &#123;</span><br><span class="line">         <span class="keyword">return</span> (<span class="xml"><span class="tag">&lt;<span class="name">Fication</span>/&gt;</span></span>)</span><br><span class="line">      &#125;&#125;,</span><br><span class="line">      &#123;<span class="attr">title</span>:<span class="string">&quot;美食地图&quot;</span>,<span class="attr">default</span>:map,<span class="attr">active</span>:map1,<span class="attr">content</span>:<span class="string">&quot;美食地图&quot;</span>,<span class="attr">renderContent</span>: <span class="function">() =&gt;</span> &#123;</span><br><span class="line">         <span class="keyword">return</span> (<span class="xml"><span class="tag">&lt;<span class="name">FoodMap</span>/&gt;</span></span>)</span><br><span class="line">      &#125;&#125;,</span><br><span class="line">      &#123;<span class="attr">title</span>:<span class="string">&quot;更多&quot;</span>,<span class="attr">default</span>:gengduo,<span class="attr">active</span>:gengduo_1,<span class="attr">content</span>:<span class="string">&quot;更多&quot;</span>,<span class="attr">renderContent</span>: <span class="function">() =&gt;</span> &#123;</span><br><span class="line">         <span class="keyword">return</span> (<span class="xml"><span class="tag">&lt;<span class="name">More</span>/&gt;</span></span>)</span><br><span class="line">      &#125;&#125;,</span><br><span class="line">   ]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//tab.jsx tab的组件  使用ant 我们开始循环上面的列表</span></span><br><span class="line"><span class="keyword">import</span> React <span class="keyword">from</span> <span class="string">&#x27;react&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123;connect&#125; <span class="keyword">from</span> <span class="string">&#x27;react-redux&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123; TabBar &#125; <span class="keyword">from</span> <span class="string">&#x27;antd-mobile&#x27;</span>;</span><br><span class="line"><span class="comment">//引入我们菜单配置列表</span></span><br><span class="line"><span class="keyword">import</span> &#123;icon&#125; <span class="keyword">from</span> <span class="string">&#x27;./tabItem.js&#x27;</span></span><br><span class="line"><span class="comment">//当我们点击的时候需要发送状态</span></span><br><span class="line"><span class="keyword">import</span> &#123;ACTIONS&#125; <span class="keyword">from</span> <span class="string">&#x27;@/store/actionsType.js&#x27;</span></span><br><span class="line"><span class="comment">//获取到菜单列表</span></span><br><span class="line"><span class="keyword">let</span> icondata = icon()</span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Tab</span> <span class="keyword">extends</span> <span class="title">React</span>.<span class="title">Component</span> </span>&#123;</span><br><span class="line">  <span class="function"><span class="title">constructor</span>(<span class="params">props</span>)</span> &#123;</span><br><span class="line">    <span class="built_in">super</span>(props);</span><br><span class="line">    <span class="built_in">this</span>.state = &#123;</span><br><span class="line">      <span class="comment">//默认显示</span></span><br><span class="line">      selectedTab: <span class="string">&#x27;菜谱大全&#x27;</span>,</span><br><span class="line">      <span class="comment">//是否隐藏  </span></span><br><span class="line">      hidden: <span class="literal">false</span>,</span><br><span class="line">      <span class="comment">//是否全屏  </span></span><br><span class="line">      fullScreen: <span class="literal">true</span>,</span><br><span class="line">    &#125;;</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="function"><span class="title">render</span>(<span class="params"></span>)</span> &#123;</span><br><span class="line">    <span class="keyword">return</span> (</span><br><span class="line">      &lt;div style=&#123;<span class="built_in">this</span>.state.fullScreen ? &#123; <span class="attr">position</span>: <span class="string">&#x27;fixed&#x27;</span>, <span class="attr">height</span>: <span class="string">&#x27;100%&#x27;</span>, <span class="attr">width</span>: <span class="string">&#x27;100%&#x27;</span>, <span class="attr">top</span>: <span class="number">0</span> &#125; : &#123; <span class="attr">height</span>: <span class="number">400</span> &#125;&#125;&gt;</span><br><span class="line">        &lt;TabBar</span><br><span class="line">          unselectedTintColor=<span class="string">&quot;#949494&quot;</span></span><br><span class="line">          tintColor=<span class="string">&quot;#33A3F4&quot;</span></span><br><span class="line">          barTintColor=<span class="string">&quot;white&quot;</span></span><br><span class="line">          hidden=&#123;<span class="built_in">this</span>.state.hidden&#125;</span><br><span class="line">          style=&#123;&#123;<span class="attr">zIndex</span>:-<span class="number">1</span>&#125;&#125;</span><br><span class="line">        &gt;</span><br><span class="line">            &#123;</span><br><span class="line">             <span class="comment">//开始循环我们的菜单列表</span></span><br><span class="line">            icondata.map(<span class="function"><span class="params">item</span> =&gt;</span> </span><br><span class="line">                &lt;TabBar.Item</span><br><span class="line">                title=&#123;item.title&#125;</span><br><span class="line">                key=&#123;item.title&#125;</span><br><span class="line">                icon=&#123;<span class="xml"><span class="tag">&lt;<span class="name">div</span> <span class="attr">style</span>=<span class="string">&#123;&#123;</span></span></span></span><br><span class="line"><span class="xml">                  width: &#x27;22px&#x27;,</span></span><br><span class="line"><span class="xml">                  height: &#x27;22px&#x27;,</span></span><br><span class="line"><span class="xml">                  background: `url($&#123;item.default&#125;) center center /  21px 21px no-repeat` &#125;&#125;</span></span><br><span class="line"><span class="xml">                /&gt;</span></span><br><span class="line">                &#125;</span><br><span class="line">                selectedIcon=&#123;<span class="xml"><span class="tag">&lt;<span class="name">div</span> <span class="attr">style</span>=<span class="string">&#123;&#123;</span></span></span></span><br><span class="line"><span class="xml">                  width: &#x27;22px&#x27;,</span></span><br><span class="line"><span class="xml">                  height: &#x27;22px&#x27;,</span></span><br><span class="line"><span class="xml">                  background: `url($&#123;item.active&#125;) center center /  21px 21px no-repeat` &#125;&#125;</span></span><br><span class="line"><span class="xml">                /&gt;</span></span><br><span class="line">                &#125;</span><br><span class="line">                selected=&#123;<span class="built_in">this</span>.state.selectedTab === <span class="string">`<span class="subst">$&#123;item.title&#125;</span>`</span>&#125;</span><br><span class="line">                onPress=&#123;<span class="function">() =&gt;</span> &#123;</span><br><span class="line">                  <span class="built_in">this</span>.setState(&#123;</span><br><span class="line">                    selectedTab: <span class="string">`<span class="subst">$&#123;item.title&#125;</span>`</span></span><br><span class="line">                  &#125;);</span><br><span class="line">                  <span class="comment">//三、然后我们就可以使用this.props 触发这个函数 传入我们 需要的值 也就是TAB的每一项</span></span><br><span class="line">                  <span class="built_in">this</span>.props.setHeader(item.title)</span><br><span class="line">                &#125;&#125;</span><br><span class="line">              &gt;</span><br><span class="line">                &#123;<span class="comment">/*当点击菜单每项的时候 对应的调取我们循环中的renderContent函数 返回对应要显示的组件*/</span>&#125;       </span><br><span class="line">                &#123;item.renderContent()&#125;</span><br><span class="line">              &lt;/TabBar.Item&gt;</span><br><span class="line">            )&#125;</span><br><span class="line">        &lt;/TabBar&gt;</span><br><span class="line">      &lt;/div&gt;</span><br><span class="line">    );</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//二、这是我们传入的第二个函数 首先它必须要返回一个对象 默认形参会有dipatch </span></span><br><span class="line"><span class="comment">//这样就把我们返回的对象 挂载到了我们当前实例上 props 上 </span></span><br><span class="line"><span class="keyword">const</span> setHeader = <span class="function">(<span class="params">dispatch</span>) =&gt;</span> &#123;</span><br><span class="line">  <span class="keyword">return</span> &#123;</span><br><span class="line">    setHeader:<span class="function">(<span class="params">data</span>) =&gt;</span> &#123;</span><br><span class="line">      dispatch(&#123;<span class="attr">type</span>:ACTIONS.SETHEADER,data&#125;)</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//一、首先要引入我们的 conect 从react-redux中 </span></span><br><span class="line"><span class="comment">//然后把我们的组件包装一下 从而 让我们传入的函数 能挂载到props上</span></span><br><span class="line"><span class="comment">//由于我们这里是 点击tab 改变公共数据 所以这里我们之传入第二个参数</span></span><br><span class="line"><span class="keyword">const</span> showmap = <span class="function"><span class="params">state</span> =&gt;</span> &#123;</span><br><span class="line">  <span class="keyword">return</span> &#123;</span><br><span class="line">    ...state</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> connect(showmap,setHeader)(Tab)</span><br></pre></td></tr></table></figure>
<h3 id="公共的头部"><a href="#公共的头部" class="headerlink" title="公共的头部"></a>公共的头部</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>这里主要就是从我们tab里取出对应的title 然后显示在我们的头部上</span><br><span class="line"><span class="number">2.</span>当我们是分类的之后 头部的渲染 就要不一样</span><br><span class="line"><span class="number">3.</span>分类的头部 由于上面还有页面的切换 所以我们要单独设置在分类里</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//header.jsx</span></span><br><span class="line"><span class="keyword">import</span> React <span class="keyword">from</span> <span class="string">&#x27;react&#x27;</span></span><br><span class="line"><span class="keyword">import</span> header <span class="keyword">from</span> <span class="string">&#x27;./header.css&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123;connect&#125; <span class="keyword">from</span> <span class="string">&#x27;react-redux&#x27;</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Header</span> <span class="keyword">extends</span> <span class="title">React</span>.<span class="title">Component</span></span>&#123;</span><br><span class="line">    <span class="function"><span class="title">render</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="keyword">return</span>(</span><br><span class="line">        &#123;<span class="comment">/*如果我从reducer里取出来的时候分类的时候 我就什么也不显示 反之我就显示我应该显示的*/</span>&#125;    </span><br><span class="line">        <span class="built_in">this</span>.props.header === <span class="string">&#x27;分类&#x27;</span>?<span class="string">&#x27;&#x27;</span>:<span class="xml"><span class="tag">&lt;<span class="name">div</span> <span class="attr">className</span>=<span class="string">&#x27;title&#x27;</span>&gt;</span>&#123;this.props.header&#125;<span class="tag">&lt;/<span class="name">div</span>&gt;</span></span></span><br><span class="line">        )  </span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//二 在connect传入的第第一个函数 这个默认的形参 就是 你的状态数据 如果有改变 就是你改变之后的状态数据  </span></span><br><span class="line"><span class="comment">//并且 把这个函数的返回值 挂载到了我们的props上 我们就可以通过this.props去使用了</span></span><br><span class="line"><span class="keyword">const</span> getTitle = <span class="function">(<span class="params">state</span>)  =&gt;</span> &#123;</span><br><span class="line">    <span class="keyword">return</span> &#123;</span><br><span class="line">        ...state</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//一、我们的header需要使用这个公共数据 所以传入一个对象进去</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> connect(getTitle)(Header)</span><br></pre></td></tr></table></figure>
<h3 id="Layout布局"><a href="#Layout布局" class="headerlink" title="Layout布局"></a>Layout布局</h3><figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>主要就是存放了 tab 和 header组件 </span><br><span class="line"><span class="number">2.</span>因为 头部是公共的 所以单独拿出来写了</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> React <span class="keyword">from</span> <span class="string">&#x27;react&#x27;</span></span><br><span class="line"><span class="comment">// import &#123;Route&#125; from &#x27;react-router-dom&#x27;</span></span><br><span class="line"><span class="keyword">import</span> Header <span class="keyword">from</span> <span class="string">&#x27;./header/Header&#x27;</span></span><br><span class="line"><span class="keyword">import</span> Tap <span class="keyword">from</span> <span class="string">&#x27;./Tab/Tab.jsx&#x27;</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Layout</span> <span class="keyword">extends</span> <span class="title">React</span>.<span class="title">Component</span></span>&#123;</span><br><span class="line">    <span class="function"><span class="title">render</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="keyword">return</span>(</span><br><span class="line">            &lt;div&gt;</span><br><span class="line">                &lt;Header&gt;&lt;/Header&gt;</span><br><span class="line">                &lt;Tap/&gt;</span><br><span class="line">            &lt;/div&gt;</span><br><span class="line">        )</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> Layout</span><br></pre></td></tr></table></figure>
<h3 id="首页的轮播图-及-精品好菜"><a href="#首页的轮播图-及-精品好菜" class="headerlink" title="首页的轮播图 及 精品好菜"></a>首页的轮播图 及 精品好菜</h3><figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>我们首页的轮播是发送请求 获取到的数据 数据在mock文件夹下 需要用json-server启动</span><br><span class="line"><span class="number">2.</span>然后我们的精品好菜使用的数据 和轮播图的数据是一样的 </span><br><span class="line"><span class="number">3.</span>所以我们在home组件一加载的时候 就要去发请求</span><br><span class="line"><span class="number">4.</span>我们这里是通过redux-saga 去完成异步请求的时候 然后存放在对应我们轮播图的rreducer里</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//home.jsx 里面我们把各个模块都封装成了组件</span></span><br><span class="line"><span class="keyword">import</span> React <span class="keyword">from</span> <span class="string">&#x27;react&#x27;</span></span><br><span class="line"><span class="keyword">import</span> home <span class="keyword">from</span> <span class="string">&#x27;./home.css&#x27;</span></span><br><span class="line"><span class="comment">//轮播图的组件</span></span><br><span class="line"><span class="keyword">import</span> Swiper <span class="keyword">from</span> <span class="string">&#x27;./swiper/Swiper.jsx&#x27;</span></span><br><span class="line"><span class="comment">//搜索的组件</span></span><br><span class="line"><span class="keyword">import</span> Search <span class="keyword">from</span> <span class="string">&#x27;./search/Search.jsx&#x27;</span></span><br><span class="line"><span class="comment">//热门菜系的组件</span></span><br><span class="line"><span class="keyword">import</span> HotCate <span class="keyword">from</span> <span class="string">&#x27;@/views/pages/home/hotcate/Hotcate.jsx&#x27;</span></span><br><span class="line"><span class="comment">//精品好菜的组件</span></span><br><span class="line"><span class="keyword">import</span> Good <span class="keyword">from</span> <span class="string">&#x27;@/views/pages/home/goodfood/Good.jsx&#x27;</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Home</span> <span class="keyword">extends</span> <span class="title">React</span>.<span class="title">Component</span></span>&#123;</span><br><span class="line">    <span class="function"><span class="title">render</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="keyword">return</span>(</span><br><span class="line">            &lt;div className=<span class="string">&#x27;home_container&#x27;</span>&gt;</span><br><span class="line">                &lt;Swiper&gt;&lt;/Swiper&gt;</span><br><span class="line">                &lt;Search&gt;&lt;/Search&gt;</span><br><span class="line">                &lt;HotCate&gt;&lt;/HotCate&gt;</span><br><span class="line">                &lt;Good/&gt;</span><br><span class="line">                &#123;<span class="comment">/* &lt;div className=&quot;home_content&quot;&gt;&lt;/div&gt; */</span>&#125;</span><br><span class="line">            &lt;/div&gt;</span><br><span class="line">        )</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> Home</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//轮播图 swiper.jsx </span></span><br><span class="line"><span class="keyword">import</span> React <span class="keyword">from</span> <span class="string">&#x27;react&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123;connect&#125; <span class="keyword">from</span> <span class="string">&#x27;react-redux&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123; Carousel &#125; <span class="keyword">from</span> <span class="string">&#x27;antd-mobile&#x27;</span>;</span><br><span class="line"><span class="comment">//我们把对应要发送的action都封装到一个常量里 到时候要发送的action的时候 type 状态我们直接调用即可</span></span><br><span class="line"><span class="keyword">import</span> &#123;ACTIONS&#125; <span class="keyword">from</span> <span class="string">&#x27;@/store/actionsType.js&#x27;</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Swiper</span> <span class="keyword">extends</span> <span class="title">React</span>.<span class="title">Component</span></span>&#123;</span><br><span class="line">    state = &#123;</span><br><span class="line">        imgHeight: <span class="number">176</span>,</span><br><span class="line">      &#125;</span><br><span class="line">      <span class="function"><span class="title">componentDidMount</span>(<span class="params"></span>)</span> &#123;</span><br><span class="line">       <span class="comment">//在组件被加载的时候我们就需要获去发送 状态</span></span><br><span class="line">        <span class="built_in">this</span>.props.setSwiperList()</span><br><span class="line">      &#125;</span><br><span class="line">      <span class="function"><span class="title">render</span>(<span class="params"></span>)</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> (</span><br><span class="line">            &lt;Carousel</span><br><span class="line">              autoplay=&#123;<span class="literal">true</span>&#125;</span><br><span class="line">              infinite</span><br><span class="line">            &gt;</span><br><span class="line">              &#123;<span class="comment">/*拿到数据后 遍历我们的轮播图*/</span>&#125;</span><br><span class="line">              &#123;<span class="built_in">this</span>.props.swiper.map(<span class="function"><span class="params">val</span> =&gt;</span> (</span><br><span class="line">                &lt;a</span><br><span class="line">                  key=&#123;val&#125;</span><br><span class="line">                  href=<span class="string">&quot;http://www.alipay.com&quot;</span></span><br><span class="line">                  style=&#123;&#123; <span class="attr">display</span>: <span class="string">&#x27;inline-block&#x27;</span>, <span class="attr">width</span>: <span class="string">&#x27;100%&#x27;</span>, <span class="attr">height</span>: <span class="built_in">this</span>.state.imgHeight &#125;&#125;</span><br><span class="line">                &gt;</span><br><span class="line">                  &lt;img</span><br><span class="line">                    src=&#123;val.img&#125;</span><br><span class="line">                    alt=<span class="string">&quot;&quot;</span></span><br><span class="line">                    style=&#123;&#123; <span class="attr">width</span>: <span class="string">&#x27;100%&#x27;</span>, <span class="attr">verticalAlign</span>: <span class="string">&#x27;top&#x27;</span> &#125;&#125;</span><br><span class="line">                    onLoad=&#123;<span class="function">() =&gt;</span> &#123;</span><br><span class="line">                      <span class="comment">// fire window resize event to change height</span></span><br><span class="line">                      <span class="built_in">window</span>.dispatchEvent(<span class="keyword">new</span> Event(<span class="string">&#x27;resize&#x27;</span>));</span><br><span class="line">                      <span class="built_in">this</span>.setState(&#123; <span class="attr">imgHeight</span>: <span class="string">&#x27;auto&#x27;</span> &#125;);</span><br><span class="line">                    &#125;&#125;</span><br><span class="line">                  /&gt;</span><br><span class="line">                &lt;/a&gt;</span><br><span class="line">              ))&#125;</span><br><span class="line">            &lt;/Carousel&gt;</span><br><span class="line">        );</span><br><span class="line">      &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">const</span> setList = <span class="function">(<span class="params">dispatch</span>) =&gt;</span> &#123;</span><br><span class="line">  <span class="keyword">return</span>&#123;</span><br><span class="line">    setSwiperList:<span class="function">() =&gt;</span> &#123;</span><br><span class="line">      dispatch(&#123;</span><br><span class="line">        type:ACTIONS.GETSWIPER</span><br><span class="line">      &#125;)</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">const</span> getList = <span class="function">(<span class="params">state</span>) =&gt;</span> &#123;</span><br><span class="line">  <span class="keyword">return</span> &#123;</span><br><span class="line">    ...state</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//connect的第一个参数 是一个函数 用来获取我们reducer里的状态 第二个函数 是用来发送ation</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> connect(getList,setList)(Swiper)</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>轮播图组件被加载 我们就去发送action到reducer 这个时候只是告诉我们的reducer我要获取轮播图的数据了什么也不做</span><br><span class="line"><span class="number">2.</span>当我们发送action之后 redux-saga 中的takeEvery也会监听到你发送的这个aciton 然后我们去发送请求 </span><br><span class="line"><span class="number">3.</span>请求回来以后 我们在用put在去发送action 并传入我们请求回来的轮播图数据</span><br><span class="line"><span class="number">4.</span>然后我们的swiper 就去取我们的数据 第一次取是空的然后 由于reducer的数据有了 状态发生改变 就会在取</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//saga 的配置  store index.js文件 用来创建store 合并 reducer 运行saga中间件</span></span><br><span class="line"><span class="keyword">import</span> &#123; createStore,combineReducers,applyMiddleware&#125; <span class="keyword">from</span> <span class="string">&#x27;redux&#x27;</span></span><br><span class="line"><span class="comment">//saga的中间件</span></span><br><span class="line"><span class="keyword">import</span> createSagaMiddleware <span class="keyword">from</span> <span class="string">&#x27;redux-saga&#x27;</span></span><br><span class="line"><span class="comment">//hader的 reudcer 里面是 header的一些公共数据</span></span><br><span class="line"><span class="keyword">import</span> &#123;header&#125; <span class="keyword">from</span> <span class="string">&#x27;./header.js&#x27;</span></span><br><span class="line"><span class="comment">//轮播的reducer 里面是 轮播图的一些公共数据</span></span><br><span class="line"><span class="keyword">import</span> &#123;swiper&#125; <span class="keyword">from</span> <span class="string">&#x27;./swiper.js&#x27;</span></span><br><span class="line"><span class="comment">//分类的reducer 里面是 分类的一些公共数据</span></span><br><span class="line"><span class="keyword">import</span> &#123;facation&#125; <span class="keyword">from</span> <span class="string">&#x27;./facation.js&#x27;</span></span><br><span class="line"><span class="comment">//控制地图的reducer 里面是 是地图的一些 公共数据</span></span><br><span class="line"><span class="keyword">import</span> &#123;showMap&#125; <span class="keyword">from</span> <span class="string">&#x27;./showmap.js&#x27;</span></span><br><span class="line"><span class="comment">//总控制saga 里面汇总了 轮播图的saga 或者 header的saga 如果还有其他的话</span></span><br><span class="line"><span class="keyword">import</span> &#123;defsaga&#125; <span class="keyword">from</span> <span class="string">&#x27;./sagas.js&#x27;</span></span><br><span class="line"><span class="comment">//  创建saga中间件</span></span><br><span class="line"><span class="keyword">const</span> sagaMiddleware  = createSagaMiddleware()</span><br><span class="line"><span class="keyword">export</span> <span class="keyword">const</span> store = createStore(</span><br><span class="line">    <span class="comment">//合并了我们的reducer</span></span><br><span class="line">    combineReducers(&#123;</span><br><span class="line">        header,</span><br><span class="line">        swiper,</span><br><span class="line">        facation,</span><br><span class="line">        showMap</span><br><span class="line">    &#125;),</span><br><span class="line">    <span class="comment">//这里一定是个空对象 第二个参数是用来初始数据的</span></span><br><span class="line">    &#123;&#125;,</span><br><span class="line">    <span class="comment">//注册我们的saga中间件 也就是让我们所有的saga 和reducer然后关联</span></span><br><span class="line">    applyMiddleware(sagaMiddleware)</span><br><span class="line">)</span><br><span class="line"><span class="comment">//然后 要运行我们的saga</span></span><br><span class="line">sagaMiddleware.run(defsaga)</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//defsaga.js 里面 是我们所有对应的saga文件的汇总 是一个生成器函数 使用all api 运行了我们的所有对应的saga文件</span></span><br><span class="line"><span class="comment">//all api 只要运行我们所有的saga文件 比如你轮播图对应的是一个saga 分类对应的又是一个saga 使用all就可以全部运行</span></span><br><span class="line"><span class="keyword">import</span> &#123; all &#125; <span class="keyword">from</span> <span class="string">&#x27;redux-saga/effects&#x27;</span></span><br><span class="line"><span class="comment">//轮播图对应的saga文件</span></span><br><span class="line"><span class="keyword">import</span> &#123;getSwiper&#125; <span class="keyword">from</span> <span class="string">&#x27;./sagas/swiperSaga.js&#x27;</span></span><br><span class="line"><span class="comment">//分类对应的saga文件</span></span><br><span class="line"><span class="keyword">import</span> &#123;facationSaga&#125; <span class="keyword">from</span> <span class="string">&#x27;./sagas/facationSaga.js&#x27;</span></span><br><span class="line"><span class="comment">//然后导出生成器函数 里面使用yield语法 并且all 运行了我们所有的saga文件</span></span><br><span class="line"><span class="keyword">export</span> <span class="function"><span class="keyword">function</span> * <span class="title">defsaga</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">yield</span> all([getSwiper(),facationSaga()])</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 轮播图对应的reducer</span></span><br><span class="line"><span class="comment">//引入了我们对用要发送action type的常量</span></span><br><span class="line"><span class="keyword">import</span> &#123;ACTIONS&#125; <span class="keyword">from</span> <span class="string">&#x27;@/store/actionsType.js&#x27;</span></span><br><span class="line"><span class="comment">//默认显示值</span></span><br><span class="line"><span class="keyword">const</span> swiperList = [&#123;</span><br><span class="line">    id:<span class="number">1</span>,</span><br><span class="line">    img:<span class="string">&#x27;https://timgsa.baidu.com/timg?image&amp;quality=80&amp;size=b9999_10000&amp;sec=1604765080706&amp;di=672462f0d791a79b644f62063dfa65cd&amp;imgtype=0&amp;src=http%3A%2F%2Fn.sinaimg.cn%2Fsinacn%2Fw640h425%2F20171202%2F7828-fypikwt3113517.jpg&#x27;</span></span><br><span class="line">&#125;]</span><br><span class="line"><span class="comment">//轮播图的reducer</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">const</span> swiper = <span class="function">(<span class="params">state = swiperList,action </span>) =&gt;</span> &#123;</span><br><span class="line">    <span class="comment">//刚刚在我们轮播图组件 发送的action就是ACTIONS.GETSWIPER 这个时候我们可以什么也不干或者默认返回 这个action在到reducer之后 同时也会被我们的swiper的saga文件 监听到</span></span><br><span class="line">    <span class="keyword">switch</span> (action.type)&#123;</span><br><span class="line">        <span class="keyword">case</span> ACTIONS.GETSWIPER:</span><br><span class="line">        <span class="keyword">return</span> state</span><br><span class="line">        <span class="comment">//这里就是对应我们swiper saga文件 使用put 又发送的action 然后返回了我们请求回来的数据    </span></span><br><span class="line">        <span class="keyword">case</span> ACTIONS.SETSWIPER:</span><br><span class="line">        <span class="keyword">return</span>  action.data</span><br><span class="line">        <span class="keyword">break</span></span><br><span class="line">        <span class="keyword">default</span>:</span><br><span class="line">        <span class="keyword">return</span> state</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 对应的swiper saga文件</span></span><br><span class="line"><span class="comment">//引入我们对应的action</span></span><br><span class="line"><span class="keyword">import</span> &#123;ACTIONS&#125; <span class="keyword">from</span> <span class="string">&#x27;@/store/actionsType.js&#x27;</span></span><br><span class="line"><span class="comment">//引入我们的副作用</span></span><br><span class="line"><span class="keyword">import</span> &#123;takeEvery,call,put&#125; <span class="keyword">from</span> <span class="string">&#x27;redux-saga/effects&#x27;</span></span><br><span class="line"><span class="comment">//引入我们要发送的请求 这里就是去请求后台数据封装的函数</span></span><br><span class="line"><span class="keyword">import</span> &#123;getSwiper <span class="keyword">as</span> swiper&#125; <span class="keyword">from</span> <span class="string">&#x27;@/api/swiper.js&#x27;</span></span><br><span class="line"><span class="comment">//然后导入我们的swiper saga </span></span><br><span class="line"><span class="keyword">export</span> <span class="function"><span class="keyword">function</span> * <span class="title">getSwiper</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="comment">//当我们的轮播图 第一次发送action到reducer 的时候 我们使用 takeEvery 也监听到这个action</span></span><br><span class="line">    <span class="keyword">yield</span> takeEvery(ACTIONS.GETSWIPER,<span class="function"><span class="keyword">function</span>*(<span class="params"></span>)</span>&#123;</span><br><span class="line">        	<span class="comment">//然后我们使用call 副作用 去发送了我们封装好的请求函数 并且拿到了结果	</span></span><br><span class="line">            <span class="keyword">const</span> &#123;data&#125;  = <span class="keyword">yield</span> call(swiper)</span><br><span class="line">            <span class="comment">//然后我们使用put副作用 又发送了一次action 到reducer 并且把我们请求回来的数据也发过去了</span></span><br><span class="line">            <span class="keyword">yield</span> put(&#123;</span><br><span class="line">                type:ACTIONS.SETSWIPER,</span><br><span class="line">                data:data.swiper</span><br><span class="line">            &#125;)</span><br><span class="line">    &#125;)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>以上 我们的 组件发送action 到 对应的 reducer 然后我们的saga 监听到 你发送的action 又对应发起请求后台数据 然后使用put 再次发送action 这个流程完毕以后 我们就有了轮播图的数据</span><br><span class="line"><span class="number">2.</span>我们的精品好菜模块 通过reducer 就可以拿到轮播图的数据</span><br></pre></td></tr></table></figure>
<h3 id="分类页面"><a href="#分类页面" class="headerlink" title="分类页面"></a>分类页面</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>我们的分类页面 头部 是单独在分类页面中的 上面又两个按钮 分类和食材 当我们点击切换的时候 就可以改变页面</span><br><span class="line"><span class="number">2.</span>这里没有用组件去做 而是用路由的方式去做的 组件用的都是一个 是不过 我们当点击按钮切换不同的路由组件的时候 传入的数据不同</span><br><span class="line"><span class="number">3.</span>分类 和 食材的数据 都在一个数据对象里面 只不过是我们的键名不一样</span><br><span class="line"><span class="number">4.</span>所以当我们切换分类和食材的时候 需要传入对应的数据来显示不同的页面</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//分类的主页面</span></span><br><span class="line"><span class="keyword">import</span> React <span class="keyword">from</span> <span class="string">&#x27;react&#x27;</span></span><br><span class="line"><span class="comment">//引入了 分类的头部</span></span><br><span class="line"><span class="keyword">import</span> Fheader <span class="keyword">from</span> <span class="string">&#x27;./classheader/fheader&#x27;</span></span><br><span class="line"><span class="comment">//search组件 </span></span><br><span class="line"><span class="keyword">import</span> Search <span class="keyword">from</span> <span class="string">&#x27;@/views/pages/home/search/Search.jsx&#x27;</span></span><br><span class="line"><span class="comment">//我们主页面 就是 列表页面</span></span><br><span class="line"><span class="keyword">import</span> Classify <span class="keyword">from</span> <span class="string">&#x27;./classify/classify&#x27;</span></span><br><span class="line"><span class="keyword">import</span> Material <span class="keyword">from</span> <span class="string">&#x27;./classify/classify&#x27;</span></span><br><span class="line"><span class="comment">//配置路由</span></span><br><span class="line"><span class="keyword">import</span> &#123; BrowserRouter <span class="keyword">as</span> Router,Route,Redirect,Switch &#125; <span class="keyword">from</span> <span class="string">&#x27;react-router-dom&#x27;</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Fication</span> <span class="keyword">extends</span> <span class="title">React</span>.<span class="title">Component</span></span>&#123;</span><br><span class="line">    <span class="function"><span class="title">render</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="keyword">return</span> (</span><br><span class="line">            &lt;Router&gt;</span><br><span class="line">            &lt;div className=<span class="string">&quot;fication_container&quot;</span>&gt;</span><br><span class="line">               &lt;Fheader&gt;&lt;/Fheader&gt;</span><br><span class="line">               &lt;Search&gt;&lt;/Search&gt;</span><br><span class="line">               &lt;Switch&gt;</span><br><span class="line">            	&#123;<span class="comment">/*通过给我们的列表传入不同的参数 来渲染不同的数据*/</span>&#125;</span><br><span class="line">               &lt;Route path=<span class="string">&quot;/categoryfacation&quot;</span> render=&#123;<span class="function">() =&gt;</span> <span class="xml"><span class="tag">&lt;<span class="name">Classify</span> <span class="attr">type</span>=<span class="string">&#123;</span>&#x27;<span class="attr">category</span>&#x27;&#125; <span class="attr">defaultItem</span>=<span class="string">&#123;</span>&#x27;热门&#x27;&#125;/&gt;</span></span>&#125; /&gt;</span><br><span class="line">               &lt;Route path=<span class="string">&quot;/materialfacation&quot;</span> render=&#123;<span class="function">() =&gt;</span> <span class="xml"><span class="tag">&lt;<span class="name">Material</span> <span class="attr">type</span>=<span class="string">&#123;</span>&#x27;<span class="attr">material</span>&#x27;&#125; <span class="attr">defaultItem</span>=<span class="string">&#123;</span>&#x27;肉类&#x27;&#125;/&gt;</span></span>&#125; /&gt;</span><br><span class="line">                &#123;<span class="comment">/*配置重定向 访问我们分类主页面*/</span>&#125;   </span><br><span class="line">               &lt;Redirect <span class="keyword">from</span>=<span class="string">&quot;/&quot;</span> to=<span class="string">&quot;/categoryfacation&quot;</span>/&gt;</span><br><span class="line">               &lt;/Switch&gt;   </span><br><span class="line">            &lt;/div&gt;</span><br><span class="line">            &lt;/Router&gt;</span><br><span class="line">        )</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> Fication</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//分类头部组件</span></span><br><span class="line"><span class="keyword">import</span> React <span class="keyword">from</span> <span class="string">&#x27;react&#x27;</span></span><br><span class="line"><span class="keyword">import</span> fheader <span class="keyword">from</span> <span class="string">&#x27;./fheader.css&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123; withRouter &#125; <span class="keyword">from</span> <span class="string">&#x27;react-router-dom&#x27;</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Fheader</span> <span class="keyword">extends</span> <span class="title">React</span>.<span class="title">Component</span></span>&#123;</span><br><span class="line">    <span class="function"><span class="title">constructor</span>(<span class="params">props</span>)</span>&#123;</span><br><span class="line">        <span class="built_in">super</span>(props)</span><br><span class="line">        <span class="built_in">this</span>.state = &#123;</span><br><span class="line">            currentItem :<span class="string">&#x27;left&#x27;</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="title">componentDidMount</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="comment">//这里需要判断以下 获取我们当前的路由路径 来决定 我们的默认选中状态</span></span><br><span class="line">        <span class="keyword">if</span>(<span class="built_in">this</span>.props.location.pathname === <span class="string">&#x27;/categoryfacation&#x27;</span>)&#123;</span><br><span class="line">            <span class="built_in">this</span>.setState(&#123;</span><br><span class="line">                currentItem:<span class="string">&#x27;left&#x27;</span></span><br><span class="line">            &#125;)</span><br><span class="line">        &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">            <span class="built_in">this</span>.setState(&#123;</span><br><span class="line">                currentItem:<span class="string">&#x27;right&#x27;</span></span><br><span class="line">            &#125;)</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="title">handler</span>(<span class="params">currentItem</span>)</span>&#123;</span><br><span class="line">        <span class="comment">//当点击的时候 跳转不同的组件 然后切换不同的选中状态 主要是分类 还是食材</span></span><br><span class="line">        <span class="built_in">this</span>.setState(&#123;</span><br><span class="line">            currentItem</span><br><span class="line">        &#125;)</span><br><span class="line">       <span class="keyword">switch</span> (currentItem) &#123;</span><br><span class="line">           <span class="keyword">case</span> <span class="string">&#x27;left&#x27;</span>:</span><br><span class="line">               <span class="built_in">this</span>.props.history.push(<span class="string">&#x27;/categoryfacation&#x27;</span>)</span><br><span class="line">               <span class="keyword">break</span>;</span><br><span class="line">            <span class="keyword">case</span> <span class="string">&#x27;right&#x27;</span>:</span><br><span class="line">                <span class="built_in">this</span>.props.history.push(<span class="string">&#x27;/materialfacation&#x27;</span>)</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">           <span class="keyword">default</span>:</span><br><span class="line">            <span class="built_in">this</span>.props.history.push(<span class="string">&#x27;/categoryfacation&#x27;</span>)</span><br><span class="line">               <span class="keyword">break</span>;</span><br><span class="line">       &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="title">render</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="keyword">return</span> (</span><br><span class="line">            &lt;header className=<span class="string">&#x27;fheader_title&#x27;</span>&gt;</span><br><span class="line">                &lt;ul className=<span class="string">&quot;fheader_content&quot;</span>&gt;</span><br><span class="line">                    &#123;<span class="comment">/* 这里就是根据看看我们的路由路径来 决定 默认选中 */</span>&#125;</span><br><span class="line">                    &lt;li className=&#123;<span class="built_in">this</span>.state.currentItem === <span class="string">&#x27;left&#x27;</span>?<span class="string">&#x27;last_li&#x27;</span>:<span class="string">&#x27;last_li anitate&#x27;</span>&#125; &gt;&lt;/li&gt;</span><br><span class="line">                    &lt;li className=&#123;<span class="built_in">this</span>.state.currentItem === <span class="string">&#x27;left&#x27;</span>?<span class="string">&#x27;active&#x27;</span>:<span class="string">&#x27;&#x27;</span>&#125; onClick=&#123;<span class="function">() =&gt;</span> &#123;<span class="built_in">this</span>.handler(<span class="string">&#x27;left&#x27;</span>)&#125;&#125;&gt;分类&lt;/li&gt;</span><br><span class="line">                    &lt;li className=&#123;<span class="built_in">this</span>.state.currentItem === <span class="string">&#x27;right&#x27;</span>?<span class="string">&#x27;active&#x27;</span>:<span class="string">&#x27;&#x27;</span>&#125; onClick=&#123;<span class="function">() =&gt;</span> &#123;<span class="built_in">this</span>.handler(<span class="string">&#x27;right&#x27;</span>)&#125;&#125;&gt;食材&lt;/li&gt;</span><br><span class="line">                &lt;/ul&gt;</span><br><span class="line">            &lt;/header&gt;</span><br><span class="line">        )</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> withRouter(Fheader)</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//分类页面的数据格式</span></span><br><span class="line">&#123;</span><br><span class="line">    <span class="string">&quot;ret&quot;</span>: <span class="literal">true</span>,</span><br><span class="line">    <span class="string">&quot;data&quot;</span>: &#123;</span><br><span class="line">      <span class="comment">//当时分类的时候 我们需要使用   category的数据</span></span><br><span class="line">      <span class="string">&quot;category&quot;</span>: &#123;</span><br><span class="line">        <span class="string">&quot;热门&quot;</span>: [<span class="string">&quot;饮品&quot;</span>, <span class="string">&quot;清淡&quot;</span>, <span class="string">&quot;夏季菜谱&quot;</span>, <span class="string">&quot;下饭菜&quot;</span>, <span class="string">&quot;面食&quot;</span>, <span class="string">&quot;粥&quot;</span>, <span class="string">&quot;晚餐&quot;</span>, <span class="string">&quot;汤&quot;</span>, <span class="string">&quot;面条&quot;</span>, <span class="string">&quot;汤羹&quot;</span>, <span class="string">&quot;烤箱&quot;</span>, <span class="string">&quot;中餐&quot;</span>, <span class="string">&quot;西餐&quot;</span>, <span class="string">&quot;孕妇&quot;</span>, <span class="string">&quot;蛋糕&quot;</span>, <span class="string">&quot;东北菜&quot;</span>, <span class="string">&quot;凉拌&quot;</span>, <span class="string">&quot;煲汤&quot;</span>, <span class="string">&quot;布丁&quot;</span>, <span class="string">&quot;寿司&quot;</span>, <span class="string">&quot;糕点&quot;</span>, <span class="string">&quot;糖水&quot;</span>, <span class="string">&quot;湘菜&quot;</span>, <span class="string">&quot;甜点&quot;</span>],</span><br><span class="line">        <span class="string">&quot;菜式&quot;</span>: [<span class="string">&quot;家常菜&quot;</span>, <span class="string">&quot;素菜&quot;</span>, <span class="string">&quot;凉菜&quot;</span>, <span class="string">&quot;下饭菜&quot;</span>, <span class="string">&quot;面食&quot;</span>, <span class="string">&quot;小吃&quot;</span>, <span class="string">&quot;粥&quot;</span>, <span class="string">&quot;汤&quot;</span>, <span class="string">&quot;煲汤&quot;</span>, <span class="string">&quot;私房菜&quot;</span>, <span class="string">&quot;汤羹&quot;</span>, <span class="string">&quot;糕点&quot;</span>, <span class="string">&quot;甜点&quot;</span>, <span class="string">&quot;饮品&quot;</span>, <span class="string">&quot;创意菜&quot;</span>, <span class="string">&quot;腌制&quot;</span>, <span class="string">&quot;自制蘸料&quot;</span>, <span class="string">&quot;冰品&quot;</span>, <span class="string">&quot;热菜&quot;</span>, <span class="string">&quot;农家菜&quot;</span>, <span class="string">&quot;荤菜&quot;</span>, <span class="string">&quot;主食&quot;</span>, <span class="string">&quot;宴客菜&quot;</span>, <span class="string">&quot;开胃菜&quot;</span>, <span class="string">&quot;海鲜&quot;</span>, <span class="string">&quot;下酒菜&quot;</span>, <span class="string">&quot;懒人食谱&quot;</span>, <span class="string">&quot;卤菜&quot;</span>],</span><br><span class="line">        <span class="string">&quot;菜系&quot;</span>: [<span class="string">&quot;川菜&quot;</span>, <span class="string">&quot;东北菜&quot;</span>, <span class="string">&quot;粤菜&quot;</span>, <span class="string">&quot;湘菜&quot;</span>, <span class="string">&quot;西餐&quot;</span>, <span class="string">&quot;鲁菜&quot;</span>, <span class="string">&quot;韩式料理&quot;</span>, <span class="string">&quot;日式料理&quot;</span>, <span class="string">&quot;淮扬菜&quot;</span>, <span class="string">&quot;闽菜&quot;</span>, <span class="string">&quot;浙菜&quot;</span>, <span class="string">&quot;徽菜&quot;</span>, <span class="string">&quot;清真&quot;</span>, <span class="string">&quot;苏菜&quot;</span>, <span class="string">&quot;东南亚&quot;</span>, <span class="string">&quot;贵州菜&quot;</span>, <span class="string">&quot;本帮菜&quot;</span>, <span class="string">&quot;法国菜&quot;</span>, <span class="string">&quot;新疆菜&quot;</span>, <span class="string">&quot;潮州菜&quot;</span>, <span class="string">&quot;客家菜&quot;</span>, <span class="string">&quot;意大利菜&quot;</span>, <span class="string">&quot;泰国菜&quot;</span>, <span class="string">&quot;英国菜&quot;</span>, <span class="string">&quot;台湾美食&quot;</span>, <span class="string">&quot;香港美食&quot;</span>, <span class="string">&quot;豫菜&quot;</span>, <span class="string">&quot;印度菜&quot;</span>, <span class="string">&quot;云南菜&quot;</span>, <span class="string">&quot;西班牙菜&quot;</span>, <span class="string">&quot;赣菜&quot;</span>, <span class="string">&quot;京菜&quot;</span>, <span class="string">&quot;澳大利亚菜&quot;</span>, <span class="string">&quot;晋菜&quot;</span>, <span class="string">&quot;鄂菜&quot;</span>],</span><br><span class="line">        <span class="string">&quot;特色&quot;</span>: [<span class="string">&quot;泡菜&quot;</span>, <span class="string">&quot;冰淇淋&quot;</span>, <span class="string">&quot;粽子&quot;</span>, <span class="string">&quot;沙拉&quot;</span>, <span class="string">&quot;油条&quot;</span>, <span class="string">&quot;豆浆&quot;</span>, <span class="string">&quot;零食&quot;</span>, <span class="string">&quot;布丁&quot;</span>, <span class="string">&quot;糖水&quot;</span>, <span class="string">&quot;自制食材&quot;</span>, <span class="string">&quot;果汁&quot;</span>, <span class="string">&quot;果冻&quot;</span>, <span class="string">&quot;糖果&quot;</span>, <span class="string">&quot;果茶&quot;</span>, <span class="string">&quot;酸菜&quot;</span>, <span class="string">&quot;青团&quot;</span>, <span class="string">&quot;香锅&quot;</span>, <span class="string">&quot;饮料&quot;</span>],</span><br><span class="line">        <span class="string">&quot;烘焙&quot;</span>: [<span class="string">&quot;蛋糕&quot;</span>, <span class="string">&quot;披萨&quot;</span>, <span class="string">&quot;面包&quot;</span>, <span class="string">&quot;月饼&quot;</span>, <span class="string">&quot;吐司&quot;</span>, <span class="string">&quot;饼干&quot;</span>, <span class="string">&quot;杯子蛋糕&quot;</span>, <span class="string">&quot;蛋挞&quot;</span>, <span class="string">&quot;曲奇&quot;</span>, <span class="string">&quot;派&quot;</span>, <span class="string">&quot;泡芙&quot;</span>, <span class="string">&quot;慕斯&quot;</span>, <span class="string">&quot;小蛋糕&quot;</span>, <span class="string">&quot;马卡龙&quot;</span>, <span class="string">&quot;戚风蛋糕&quot;</span>, <span class="string">&quot;提拉米苏&quot;</span>, <span class="string">&quot;海绵蛋糕&quot;</span>, <span class="string">&quot;奶油蛋糕&quot;</span>, <span class="string">&quot;挞&quot;</span>, <span class="string">&quot;翻糖蛋糕&quot;</span>, <span class="string">&quot;磅蛋糕&quot;</span>],</span><br><span class="line">        <span class="string">&quot;主食&quot;</span>: [<span class="string">&quot;寿司&quot;</span>, <span class="string">&quot;饼&quot;</span>, <span class="string">&quot;炒饭&quot;</span>, <span class="string">&quot;馒头&quot;</span>, <span class="string">&quot;饺子&quot;</span>, <span class="string">&quot;炒面&quot;</span>],</span><br><span class="line">        <span class="string">&quot;器具&quot;</span>: [<span class="string">&quot;烤箱&quot;</span>, <span class="string">&quot;炒锅&quot;</span>, <span class="string">&quot;微波炉&quot;</span>],</span><br><span class="line">        <span class="string">&quot;烹饪方式&quot;</span>: [<span class="string">&quot;烘焙&quot;</span>, <span class="string">&quot;拌&quot;</span>, <span class="string">&quot;火锅&quot;</span>, <span class="string">&quot;蒸&quot;</span>, <span class="string">&quot;煮&quot;</span>, <span class="string">&quot;卤&quot;</span>],</span><br><span class="line">        <span class="string">&quot;口味&quot;</span>: [<span class="string">&quot;清淡&quot;</span>, <span class="string">&quot;咖喱&quot;</span>, <span class="string">&quot;麻辣&quot;</span>, <span class="string">&quot;香辣&quot;</span>],</span><br><span class="line">        <span class="string">&quot;场合&quot;</span>: [<span class="string">&quot;早餐&quot;</span>, <span class="string">&quot;晚餐&quot;</span>, <span class="string">&quot;中餐&quot;</span>, <span class="string">&quot;下午茶&quot;</span>, <span class="string">&quot;宵夜&quot;</span>, <span class="string">&quot;熬夜餐&quot;</span>, <span class="string">&quot;春季菜谱&quot;</span>, <span class="string">&quot;早茶&quot;</span>, <span class="string">&quot;夏季菜谱&quot;</span>, <span class="string">&quot;秋季菜谱&quot;</span>, <span class="string">&quot;冬季菜谱&quot;</span>, <span class="string">&quot;朋友聚餐&quot;</span>, <span class="string">&quot;二人世界&quot;</span>, <span class="string">&quot;户外野炊&quot;</span>, <span class="string">&quot;深夜食堂&quot;</span>, <span class="string">&quot;单身食谱&quot;</span>, <span class="string">&quot;早午餐&quot;</span>],</span><br><span class="line">        <span class="string">&quot;节日&quot;</span>: [<span class="string">&quot;春节&quot;</span>, <span class="string">&quot;年夜饭&quot;</span>, <span class="string">&quot;中秋节&quot;</span>, <span class="string">&quot;元旦&quot;</span>]</span><br><span class="line">      &#125;,</span><br><span class="line">       <span class="comment">//当时食材的时候 我们需要使用    material 数据</span></span><br><span class="line">      <span class="string">&quot;material&quot;</span>: &#123;</span><br><span class="line">        <span class="string">&quot;肉类&quot;</span>: [<span class="string">&quot;猪肉&quot;</span>, <span class="string">&quot;排骨&quot;</span>, <span class="string">&quot;猪蹄&quot;</span>, <span class="string">&quot;牛肉&quot;</span>],</span><br><span class="line">        <span class="string">&quot;蛋/奶&quot;</span>: [<span class="string">&quot;鸡蛋&quot;</span>, <span class="string">&quot;鸭蛋&quot;</span>, <span class="string">&quot;鹌鹑蛋&quot;</span>, <span class="string">&quot;咸鸭蛋&quot;</span>, <span class="string">&quot;松花蛋&quot;</span>],</span><br><span class="line">        <span class="string">&quot;鱼类&quot;</span>: [<span class="string">&quot;草鱼&quot;</span>, <span class="string">&quot;鲤鱼&quot;</span>, <span class="string">&quot;鲫鱼&quot;</span>],</span><br><span class="line">        <span class="string">&quot;水产&quot;</span>: [<span class="string">&quot;虾&quot;</span>, <span class="string">&quot;虾米&quot;</span>, <span class="string">&quot;龙虾&quot;</span>, <span class="string">&quot;河虾&quot;</span>],</span><br><span class="line">        <span class="string">&quot;蔬菜&quot;</span>: [<span class="string">&quot;白菜&quot;</span>, <span class="string">&quot;油菜&quot;</span>, <span class="string">&quot;芹菜&quot;</span>, <span class="string">&quot;菠菜&quot;</span>, <span class="string">&quot;茼蒿&quot;</span>],</span><br><span class="line">        <span class="string">&quot;豆类&quot;</span>: [<span class="string">&quot;绿豆芽&quot;</span>, <span class="string">&quot;黄豆芽&quot;</span>, <span class="string">&quot;黄豆&quot;</span>],</span><br><span class="line">        <span class="string">&quot;果品类&quot;</span>: [<span class="string">&quot;苹果&quot;</span>, <span class="string">&quot;香蕉&quot;</span>],</span><br><span class="line">        <span class="string">&quot;五谷杂粮&quot;</span>: [<span class="string">&quot;荞麦面&quot;</span>, <span class="string">&quot;麦芽&quot;</span>, <span class="string">&quot;小米&quot;</span>],</span><br><span class="line">        <span class="string">&quot;药食&quot;</span>: [<span class="string">&quot;燕窝&quot;</span>, <span class="string">&quot;人参&quot;</span>],</span><br><span class="line">        <span class="string">&quot;调味品&quot;</span>: [<span class="string">&quot;榨菜&quot;</span>, <span class="string">&quot;冬菜&quot;</span>],</span><br><span class="line">        <span class="string">&quot;其他&quot;</span>: [<span class="string">&quot;巧克力&quot;</span>]</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//分类 和 食材 显示页面  classify.jsx</span></span><br><span class="line"><span class="keyword">import</span> React <span class="keyword">from</span> <span class="string">&#x27;react&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123; connect &#125; <span class="keyword">from</span> <span class="string">&#x27;react-redux&#x27;</span></span><br><span class="line"><span class="keyword">import</span> classify <span class="keyword">from</span> <span class="string">&#x27;./classify.css&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123;ACTIONS&#125; <span class="keyword">from</span> <span class="string">&#x27;@/store/actionsType.js&#x27;</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Classify</span> <span class="keyword">extends</span> <span class="title">React</span>.<span class="title">Component</span></span>&#123;</span><br><span class="line">    <span class="function"><span class="title">constructor</span>(<span class="params">props</span>)</span>&#123;</span><br><span class="line">        <span class="built_in">super</span>(props)</span><br><span class="line">        <span class="built_in">this</span>.state = &#123;</span><br><span class="line">            leftList:&#123;&#125;,</span><br><span class="line">            currentIndex:<span class="number">0</span>,</span><br><span class="line">            <span class="comment">//接收从外部传过来的数据 主要用来当我们点击的时候切换显示的数据</span></span><br><span class="line">            currentItem:<span class="built_in">this</span>.props.defaultItem,</span><br><span class="line">            <span class="comment">//接收从外部传过来的类型 </span></span><br><span class="line">            currentType:<span class="built_in">this</span>.props.type</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//这里存在一个问题 我们每次切换 分类和食材的时候 你state数据不会改变 但是你组件传过来的数据是改变的 所以我们需要下面的生命周期函数来 判断看看新传进来的数据和我们的上一次的state数据相同不 如果不相同 就说明你切换了 但是我们的state数据还没有变换过来 所以 需要重新设置以下数据 然后会再次调用render函数渲染</span></span><br><span class="line">    <span class="keyword">static</span> <span class="function"><span class="title">getDerivedStateFromProps</span>(<span class="params">nextProps, prevState</span>)</span> &#123;</span><br><span class="line">        <span class="keyword">if</span>(nextProps.type !== prevState.currentType)&#123;</span><br><span class="line">            <span class="keyword">return</span> &#123;</span><br><span class="line">               ...prevState,</span><br><span class="line">               currentType:nextProps.type,</span><br><span class="line">               currentItem:nextProps.defaultItem </span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">null</span></span><br><span class="line">      &#125;</span><br><span class="line">    <span class="comment">//在组件刚开的时候去发送action到redcer 然后对应的saga 监听到了之后 在去使用takeEvery监听以下 在发送请求再次是用put发送action</span></span><br><span class="line">    <span class="function"><span class="title">componentDidMount</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="built_in">this</span>.props.getList()</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//点击列表每项的时候 设置默认显示类</span></span><br><span class="line">    <span class="function"><span class="title">handler</span>(<span class="params">index,item</span>)</span>&#123;</span><br><span class="line">        <span class="built_in">this</span>.setState(&#123;</span><br><span class="line">            currentIndex:index,</span><br><span class="line">            currentItem:item</span><br><span class="line">        &#125;)</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="title">render</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="comment">//看看 我们请求回来的数据 在组件中是哪个对象 然后 显示左侧对应的数据</span></span><br><span class="line">        <span class="keyword">const</span> leftContent = <span class="built_in">this</span>.props.facation[<span class="built_in">this</span>.state.currentType]? <span class="built_in">Object</span>.keys(<span class="built_in">this</span>.props.facation[<span class="built_in">this</span>.state.currentType]) : []</span><br><span class="line">        <span class="comment">//根据 默认选中的左侧数据 来 显示右侧中的数据是哪一项</span></span><br><span class="line">        <span class="keyword">const</span> rightContent =leftContent.length !== <span class="number">0</span>? <span class="built_in">this</span>.props.facation[<span class="built_in">this</span>.state.currentType][<span class="built_in">this</span>.state.currentItem] : []</span><br><span class="line">        <span class="keyword">return</span>(</span><br><span class="line">            &lt;div className=<span class="string">&quot;classify_container&quot;</span>&gt;</span><br><span class="line">               &lt;div className=<span class="string">&quot;classify_left&quot;</span>&gt;</span><br><span class="line">                    &lt;ul&gt;</span><br><span class="line">                        &#123;</span><br><span class="line">                           leftContent.map(<span class="function">(<span class="params">item,index</span>) =&gt;</span> &#123;</span><br><span class="line">                            <span class="keyword">return</span> <span class="xml"><span class="tag">&lt;<span class="name">li</span> <span class="attr">key</span>=<span class="string">&#123;item&#125;</span> <span class="attr">className</span>=<span class="string">&#123;this.state.currentItem</span> === <span class="string">item?</span>&#x27;<span class="attr">classify_active</span>&#x27;<span class="attr">:</span>&#x27;&#x27;&#125; <span class="attr">onClick</span>=<span class="string">&#123;()</span> =&gt;</span> &#123;this.handler(index,item)&#125;&#125;&gt;&#123;item&#125;<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span></span><br><span class="line">                           &#125;)</span><br><span class="line">                        &#125;</span><br><span class="line">                    &lt;/ul&gt;</span><br><span class="line">                    </span><br><span class="line">               &lt;/div&gt;</span><br><span class="line">               &lt;div className=<span class="string">&quot;classify_right&quot;</span>&gt;</span><br><span class="line">                    &lt;ul&gt;</span><br><span class="line">                       &#123;rightContent &amp;&amp; rightContent.map( <span class="function">(<span class="params">item,index</span>) =&gt;</span> </span><br><span class="line">                        &lt;li key=&#123;index&#125;&gt;&#123;item&#125;&lt;/li&gt;</span><br><span class="line">                        )&#125;</span><br><span class="line">                    &lt;/ul&gt;</span><br><span class="line">               &lt;/div&gt;</span><br><span class="line">            &lt;/div&gt;</span><br><span class="line">        )</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">const</span> mapState = <span class="function">(<span class="params">state</span>) =&gt;</span> &#123;</span><br><span class="line">    <span class="keyword">return</span> &#123;</span><br><span class="line">        ...state</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">const</span> getList = <span class="function">(<span class="params">dispatch</span>) =&gt;</span> &#123;</span><br><span class="line">    <span class="keyword">return</span> &#123;</span><br><span class="line">        getList:<span class="function">() =&gt;</span> &#123;</span><br><span class="line">            dispatch(&#123;</span><br><span class="line">                type:ACTIONS.GETFACATION</span><br><span class="line">            &#125;)</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> connect(mapState,getList)(Classify)</span><br></pre></td></tr></table></figure>
<h3 id="美食地图"><a href="#美食地图" class="headerlink" title="美食地图"></a>美食地图</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>这里我们使用的百度地图的API </span><br><span class="line"><span class="number">2.</span>在组件中我们使用的iframe页面指向了一个html</span><br><span class="line"><span class="number">3.</span>由于我们是打包在 public 文件夹里面的 所以这里的路径我们直接引入就好</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> React <span class="keyword">from</span> <span class="string">&#x27;react&#x27;</span></span><br><span class="line"><span class="keyword">import</span> mapcss <span class="keyword">from</span> <span class="string">&#x27;./map.css&#x27;</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">FoodMap</span> <span class="keyword">extends</span> <span class="title">React</span>.<span class="title">Component</span></span>&#123;</span><br><span class="line">    <span class="function"><span class="title">render</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="keyword">return</span> (</span><br><span class="line">            &lt;div className=<span class="string">&quot;map_container&quot;</span>&gt;</span><br><span class="line">                &lt;iframe src=<span class="string">&quot;/map.html&quot;</span>  frameBorder=<span class="string">&quot;0&quot;</span> style=&#123;&#123;<span class="attr">width</span>:<span class="string">&#x27;100%&#x27;</span>,<span class="attr">height</span>:<span class="string">&#x27;100%&#x27;</span>&#125;&#125;&gt;&lt;/iframe&gt;</span><br><span class="line">            &lt;/div&gt;</span><br><span class="line">        )</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> FoodMap</span><br></pre></td></tr></table></figure>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!--这个html页面里面我们就引入了百度地图的 详细的请见官网的API--&gt;</span></span><br><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span> </span><br><span class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span> </span><br><span class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">&quot;viewport&quot;</span> <span class="attr">content</span>=<span class="string">&quot;initial-scale=1.0, user-scalable=no&quot;</span> /&gt;</span> </span><br><span class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">http-equiv</span>=<span class="string">&quot;Content-Type&quot;</span> <span class="attr">content</span>=<span class="string">&quot;text/html; charset=utf-8&quot;</span> /&gt;</span> </span><br><span class="line"><span class="tag">&lt;<span class="name">title</span>&gt;</span>Hello, World<span class="tag">&lt;/<span class="name">title</span>&gt;</span> </span><br><span class="line"><span class="tag">&lt;<span class="name">style</span> <span class="attr">type</span>=<span class="string">&quot;text/css&quot;</span>&gt;</span> </span><br><span class="line"><span class="css"><span class="selector-tag">html</span>&#123;<span class="attribute">height</span>:<span class="number">100%</span>&#125; </span></span><br><span class="line"><span class="css"><span class="selector-tag">body</span>&#123;<span class="attribute">height</span>:<span class="number">100%</span>;<span class="attribute">margin</span>:<span class="number">0px</span>;<span class="attribute">padding</span>:<span class="number">0px</span>&#125; </span></span><br><span class="line"><span class="css"><span class="selector-id">#container</span>&#123;<span class="attribute">height</span>:<span class="number">100%</span>&#125; </span></span><br><span class="line"><span class="tag">&lt;/<span class="name">style</span>&gt;</span> </span><br><span class="line"><span class="tag">&lt;<span class="name">script</span> <span class="attr">type</span>=<span class="string">&quot;text/javascript&quot;</span> <span class="attr">src</span>=<span class="string">&quot;https://api.map.baidu.com/api?v=1.0&amp;type=webgl&amp;ak=yZRIe3h6FHiMGsdAzExNGpsIuPKGNhrE&quot;</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span> </span><br><span class="line">  </span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span> </span><br><span class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">id</span>=<span class="string">&quot;container&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">script</span> <span class="attr">type</span>=<span class="string">&quot;text/javascript&quot;</span>&gt;</span></span><br><span class="line"><span class="javascript"><span class="keyword">var</span> map = <span class="keyword">new</span> BMapGL.Map(<span class="string">&quot;container&quot;</span>);</span></span><br><span class="line"><span class="javascript"><span class="comment">// 创建地图实例 </span></span></span><br><span class="line"><span class="javascript"><span class="keyword">var</span> point = <span class="keyword">new</span> BMapGL.Point(<span class="number">116.404</span>, <span class="number">39.915</span>);</span></span><br><span class="line"><span class="javascript"><span class="comment">// 创建点坐标 </span></span></span><br><span class="line">map.centerAndZoom(point, 15);</span><br><span class="line"><span class="javascript"><span class="comment">// 初始化地图，设置中心点坐标和地图级别 </span></span></span><br><span class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span> </span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span> </span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h3 id="更过菜单-切换tab地图的显隐"><a href="#更过菜单-切换tab地图的显隐" class="headerlink" title="更过菜单 切换tab地图的显隐"></a>更过菜单 切换tab地图的显隐</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>这里的路由就是当我们切换 滑块的时候 去发送action 把我们的状态 存放在reducer里</span><br><span class="line"><span class="number">2.</span>然后我们的tab组件菜单 根据拿到的这个状态 来重新循环我们的tab配置项 在来重新渲染</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//更多组件 more.jsx</span></span><br><span class="line"><span class="keyword">import</span> React <span class="keyword">from</span> <span class="string">&#x27;react&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123;  Switch &#125; <span class="keyword">from</span> <span class="string">&#x27;antd-mobile&#x27;</span>;</span><br><span class="line"><span class="keyword">import</span> &#123;connect&#125; <span class="keyword">from</span> <span class="string">&#x27;react-redux&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123;ACTIONS&#125; <span class="keyword">from</span> <span class="string">&#x27;@/store/actionsType&#x27;</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">More</span> <span class="keyword">extends</span> <span class="title">React</span>.<span class="title">Component</span></span>&#123;</span><br><span class="line">    state = &#123;</span><br><span class="line">        <span class="comment">//开始的时候 我们先去reducer里取状态</span></span><br><span class="line">        checked:<span class="built_in">this</span>.props.showMap</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="title">showMap</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="comment">//滑动按钮的时候 我们切换我们的reducer里的状态</span></span><br><span class="line">        <span class="built_in">this</span>.props.shocheck(<span class="built_in">this</span>.state.checked)</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="title">render</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="keyword">return</span>(</span><br><span class="line">            &lt;div style=&#123;&#123;<span class="attr">paddingTop</span>:<span class="string">&#x27;1.8rem&#x27;</span>&#125;&#125;&gt;</span><br><span class="line">                是否显示地图</span><br><span class="line">                &lt;Switch</span><br><span class="line">                    checked=&#123;<span class="built_in">this</span>.state.checked&#125;</span><br><span class="line">                    onChange=&#123;<span class="function">() =&gt;</span> &#123;</span><br><span class="line">                    <span class="built_in">this</span>.setState(&#123;</span><br><span class="line">                        checked: !<span class="built_in">this</span>.state.checked,</span><br><span class="line">                    &#125;,<span class="function">() =&gt;</span> &#123;</span><br><span class="line">                        <span class="built_in">this</span>.showMap()</span><br><span class="line">                    &#125;);                   </span><br><span class="line">                    &#125;&#125;</span><br><span class="line">                /&gt;</span><br><span class="line">            &lt;/div&gt;</span><br><span class="line">        )</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">const</span> shocheck = <span class="function">(<span class="params">dispatch</span>) =&gt;</span> &#123;</span><br><span class="line">    <span class="keyword">return</span> &#123;</span><br><span class="line">        shocheck : <span class="function">(<span class="params">data</span>) =&gt;</span> &#123;</span><br><span class="line">            dispatch(&#123;</span><br><span class="line">                type:ACTIONS.SHOWMAP,</span><br><span class="line">                data</span><br><span class="line">            &#125;)</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">const</span> showmap = <span class="function"><span class="params">state</span> =&gt;</span> &#123;</span><br><span class="line">    <span class="keyword">return</span> &#123;</span><br><span class="line">        ...state</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> connect(showmap,shocheck)(More)</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//对应的tab组件 我们在拿到是否显示地图的状态后 重新渲染 由于我们的数据 是配置列表文件 所以我们这里的逻辑是在调用render之前 先要判断一下按钮的状态 然后在取过滤菜单列表即可</span></span><br><span class="line"><span class="keyword">import</span> React <span class="keyword">from</span> <span class="string">&#x27;react&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123;connect&#125; <span class="keyword">from</span> <span class="string">&#x27;react-redux&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123; TabBar &#125; <span class="keyword">from</span> <span class="string">&#x27;antd-mobile&#x27;</span>;</span><br><span class="line"><span class="keyword">import</span> &#123;icon&#125; <span class="keyword">from</span> <span class="string">&#x27;./tabItem.js&#x27;</span></span><br><span class="line"><span class="keyword">import</span> Home <span class="keyword">from</span> <span class="string">&#x27;../../pages/home/Home.jsx&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123;ACTIONS&#125; <span class="keyword">from</span> <span class="string">&#x27;@/store/actionsType.js&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123;withRouter&#125; <span class="keyword">from</span> <span class="string">&#x27;react-router-dom&#x27;</span></span><br><span class="line"><span class="keyword">let</span> icondata = icon()</span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Tab</span> <span class="keyword">extends</span> <span class="title">React</span>.<span class="title">Component</span> </span>&#123;</span><br><span class="line">  <span class="function"><span class="title">constructor</span>(<span class="params">props</span>)</span> &#123;</span><br><span class="line">    <span class="built_in">super</span>(props);</span><br><span class="line">    <span class="built_in">this</span>.state = &#123;</span><br><span class="line">      selectedTab: <span class="string">&#x27;菜谱大全&#x27;</span>,</span><br><span class="line">      hidden: <span class="literal">false</span>,</span><br><span class="line">      fullScreen: <span class="literal">true</span>,</span><br><span class="line">      showmap:<span class="built_in">this</span>.propsshowMap,</span><br><span class="line">    &#125;;</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="function"><span class="title">renderContent</span>(<span class="params">pageText</span>)</span> &#123;</span><br><span class="line">    <span class="keyword">return</span> (</span><br><span class="line">      &lt;div style=&#123;&#123; <span class="attr">backgroundColor</span>: <span class="string">&#x27;white&#x27;</span>, <span class="attr">height</span>: <span class="string">&#x27;100%&#x27;</span>, <span class="attr">textAlign</span>: <span class="string">&#x27;center&#x27;</span> &#125;&#125;&gt;</span><br><span class="line">        &lt;div style=&#123;&#123; <span class="attr">paddingTop</span>: <span class="number">60</span> &#125;&#125;&gt;Clicked “&#123;pageText&#125;” tab， show “&#123;pageText&#125;” information&lt;/div&gt;</span><br><span class="line">        &lt;a style=&#123;&#123; <span class="attr">display</span>: <span class="string">&#x27;block&#x27;</span>, <span class="attr">marginTop</span>: <span class="number">40</span>, <span class="attr">marginBottom</span>: <span class="number">20</span>, <span class="attr">color</span>: <span class="string">&#x27;#108ee9&#x27;</span> &#125;&#125;</span><br><span class="line">          onClick=&#123;<span class="function">(<span class="params">e</span>) =&gt;</span> &#123;</span><br><span class="line">            e.preventDefault();</span><br><span class="line">            <span class="built_in">this</span>.setState(&#123;</span><br><span class="line">              hidden: !<span class="built_in">this</span>.state.hidden,</span><br><span class="line">            &#125;);</span><br><span class="line">          &#125;&#125;</span><br><span class="line">        &gt;</span><br><span class="line">          Click to show/hide tab-bar</span><br><span class="line">        &lt;/a&gt;</span><br><span class="line">        &lt;a style=&#123;&#123; <span class="attr">display</span>: <span class="string">&#x27;block&#x27;</span>, <span class="attr">marginBottom</span>: <span class="number">600</span>, <span class="attr">color</span>: <span class="string">&#x27;#108ee9&#x27;</span> &#125;&#125;</span><br><span class="line">          onClick=&#123;<span class="function">(<span class="params">e</span>) =&gt;</span> &#123;</span><br><span class="line">            e.preventDefault();</span><br><span class="line">            <span class="built_in">this</span>.setState(&#123;</span><br><span class="line">              fullScreen: !<span class="built_in">this</span>.state.fullScreen,</span><br><span class="line">            &#125;);</span><br><span class="line">          &#125;&#125;</span><br><span class="line">        &gt;</span><br><span class="line">          Click to <span class="keyword">switch</span> fullscreen</span><br><span class="line">        &lt;/a&gt;</span><br><span class="line">      &lt;/div&gt;</span><br><span class="line">    );</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="function"><span class="title">render</span>(<span class="params"></span>)</span> &#123;</span><br><span class="line">   <span class="comment">//在渲染之前判断以下我们reducer里的状态  然后决定 渲染的菜单配置列表   </span></span><br><span class="line">    <span class="keyword">if</span>(!<span class="built_in">this</span>.props.showMap)&#123;</span><br><span class="line">      icondata = icondata.filter(<span class="function"><span class="params">item</span> =&gt;</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> item.title!== <span class="string">&#x27;美食地图&#x27;</span></span><br><span class="line">      &#125;)</span><br><span class="line">    &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">      icondata = icon()</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> (</span><br><span class="line">      &lt;div style=&#123;<span class="built_in">this</span>.state.fullScreen ? &#123; <span class="attr">position</span>: <span class="string">&#x27;fixed&#x27;</span>, <span class="attr">height</span>: <span class="string">&#x27;100%&#x27;</span>, <span class="attr">width</span>: <span class="string">&#x27;100%&#x27;</span>, <span class="attr">top</span>: <span class="number">0</span> &#125; : &#123; <span class="attr">height</span>: <span class="number">400</span> &#125;&#125;&gt;</span><br><span class="line">        &lt;TabBar</span><br><span class="line">          unselectedTintColor=<span class="string">&quot;#949494&quot;</span></span><br><span class="line">          tintColor=<span class="string">&quot;#33A3F4&quot;</span></span><br><span class="line">          barTintColor=<span class="string">&quot;white&quot;</span></span><br><span class="line">          hidden=&#123;<span class="built_in">this</span>.state.hidden&#125;</span><br><span class="line">          style=&#123;&#123;<span class="attr">zIndex</span>:-<span class="number">1</span>&#125;&#125;</span><br><span class="line">        &gt;</span><br><span class="line">            &#123;</span><br><span class="line">            icondata.map(<span class="function"><span class="params">item</span> =&gt;</span> </span><br><span class="line">                &lt;TabBar.Item</span><br><span class="line">                title=&#123;item.title&#125;</span><br><span class="line">                key=&#123;item.title&#125;</span><br><span class="line">                icon=&#123;<span class="xml"><span class="tag">&lt;<span class="name">div</span> <span class="attr">style</span>=<span class="string">&#123;&#123;</span></span></span></span><br><span class="line"><span class="xml">                  width: &#x27;22px&#x27;,</span></span><br><span class="line"><span class="xml">                  height: &#x27;22px&#x27;,</span></span><br><span class="line"><span class="xml">                  background: `url($&#123;item.default&#125;) center center /  21px 21px no-repeat` &#125;&#125;</span></span><br><span class="line"><span class="xml">                /&gt;</span></span><br><span class="line">                &#125;</span><br><span class="line">                selectedIcon=&#123;<span class="xml"><span class="tag">&lt;<span class="name">div</span> <span class="attr">style</span>=<span class="string">&#123;&#123;</span></span></span></span><br><span class="line"><span class="xml">                  width: &#x27;22px&#x27;,</span></span><br><span class="line"><span class="xml">                  height: &#x27;22px&#x27;,</span></span><br><span class="line"><span class="xml">                  background: `url($&#123;item.active&#125;) center center /  21px 21px no-repeat` &#125;&#125;</span></span><br><span class="line"><span class="xml">                /&gt;</span></span><br><span class="line">                &#125;</span><br><span class="line">                selected=&#123;<span class="built_in">this</span>.state.selectedTab === <span class="string">`<span class="subst">$&#123;item.title&#125;</span>`</span>&#125;</span><br><span class="line">                onPress=&#123;<span class="function">() =&gt;</span> &#123;</span><br><span class="line">                  <span class="built_in">this</span>.setState(&#123;</span><br><span class="line">                    selectedTab: <span class="string">`<span class="subst">$&#123;item.title&#125;</span>`</span></span><br><span class="line">                  &#125;);</span><br><span class="line">                  <span class="built_in">this</span>.props.setHeader(item.title)</span><br><span class="line">                &#125;&#125;</span><br><span class="line">              &gt;</span><br><span class="line">                &#123;item.renderContent()&#125;</span><br><span class="line">              &lt;/TabBar.Item&gt;</span><br><span class="line">            )&#125;</span><br><span class="line">        &lt;/TabBar&gt;</span><br><span class="line">      &lt;/div&gt;</span><br><span class="line">    );</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">const</span> setHeader = <span class="function">(<span class="params">dispatch</span>) =&gt;</span> &#123;</span><br><span class="line">  <span class="keyword">return</span> &#123;</span><br><span class="line">    setHeader:<span class="function">(<span class="params">data</span>) =&gt;</span> &#123;</span><br><span class="line">      dispatch(&#123;<span class="attr">type</span>:ACTIONS.SETHEADER,data&#125;)</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">const</span> showmap = <span class="function"><span class="params">state</span> =&gt;</span> &#123;</span><br><span class="line">  <span class="keyword">return</span> &#123;</span><br><span class="line">    ...state</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> connect(showmap,setHeader)(Tab)</span><br></pre></td></tr></table></figure>
</article><div class="post-copyright"><div class="post-copyright__title"><span class="post-copyright-info"><h>webAPP 美食项目</h></span></div><div class="post-copyright__type"><span class="post-copyright-info"><a href="http://example.com/2019/03/24/%E7%A7%BB%E5%8A%A8%E7%AB%AF%E7%BE%8E%E9%A3%9FwebAPP-react/">http://example.com/2019/03/24/%E7%A7%BB%E5%8A%A8%E7%AB%AF%E7%BE%8E%E9%A3%9FwebAPP-react/</a></span></div><div class="post-copyright-m"><div class="post-copyright-m-info"><div class="post-copyright-a"><h>作者</h><div class="post-copyright-cc-info"><h>北城韩雨</h></div></div><div class="post-copyright-c"><h>发布于</h><div class="post-copyright-cc-info"><h>2019-03-24</h></div></div><div class="post-copyright-u"><h>更新于</h><div class="post-copyright-cc-info"><h>2019-06-03</h></div></div><div class="post-copyright-c"><h>许可协议</h><div class="post-copyright-cc-info"><a class="icon" rel="noopener" target="_blank" title="Creative Commons" href="https://creativecommons.org/"><i class="fab fa-creative-commons"></i></a><a rel="noopener" target="_blank" title="CC BY-NC-SA 4.0" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a></div></div></div></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/React/">React</a></div><div class="post_share"></div></div><link rel="stylesheet" href="/" media="defer" onload="this.media='all'"/><div class="post-reward"><button class="tip-button reward-button"><span class="tip-button__text">打赏</span><div class="coin-wrapper"><div class="coin"><div class="coin__middle"></div><div class="coin__back"></div><div class="coin__front"></div></div></div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/img/weixin.jpg" target="_blank"><img class="post-qr-code-img" src="/img/weixin.jpg" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="/img/taobao.jpg" target="_blank"><img class="post-qr-code-img" src="/img/taobao.jpg" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></button></div><script defer="defer" src="/"></script><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2019/03/25/koa/"><img class="prev-cover" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2018-07-17%2F3eca5394963b50e37b7be2ba320029ec%2F00003.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&amp;refer=http%3A%2F%2Fpic.vjshi.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530644&amp;t=10679b5732c52e39eeb588040240a790" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">Koa2</div></div></a></div><div class="next-post pull-right"><a href="/2019/03/23/React%E7%BB%84%E4%BB%B6%E7%AF%87/"><img class="next-cover" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2016-12-29%2F0604092c7129acd0f4029c6728db7fd7%2F00001.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&amp;refer=http%3A%2F%2Fpic.vjshi.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530724&amp;t=333c5056a813a542419e5b661ebcfcd9" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">React高阶应用</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/2019/03/23/React组件篇/" title="React高阶应用"><img class="cover" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2016-12-29%2F0604092c7129acd0f4029c6728db7fd7%2F00001.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&refer=http%3A%2F%2Fpic.vjshi.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1629530724&t=333c5056a813a542419e5b661ebcfcd9" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-03-23</div><div class="title">React高阶应用</div></div></a></div><div><a href="/2019/03/22/React基础/" title="React基础"><img class="cover" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcz-video-photo.oss-cn-beijing.aliyuncs.com%2F20191017%2F4cfc341591d242327b67e9ceb6953612_00002.jpg&refer=http%3A%2F%2Fcz-video-photo.oss-cn-beijing.aliyuncs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1629530702&t=80943e12d5239f63beafd6d1c540855f" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-03-22</div><div class="title">React基础</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/img/my.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">北城韩雨</div><div class="author-info__description">一个前端界的小学生</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">65</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">23</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">21</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/wazer1987"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="/wangzhengvslike@163.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content"><p>感谢访问本站，如喜欢请收藏。本站主要分享前端知识，立志成为资深前端工程师，但目前是一个前端界的小学生 若喜欢可以打赏请博主喝一杯冰阔落</p> <p>另外请大家多多支持淼哥的开源项目</p> <p>https://github.com/flipped-aurora/gin-vue-admin</p> <p>🌟🌟欢迎大家start 🌟🌟</p> <p>欢迎加入博主的前端技术交流群</p> <p style="background:rgba(255,255,255,1);margin:0"> <img src="/img/code.png"></img> </p></div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%A1%B9%E7%9B%AE%E6%A6%82%E8%BF%B0"><span class="toc-text">项目概述</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%A1%B9%E7%9B%AE%E5%8A%9F%E8%83%BD"><span class="toc-text">项目功能</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8A%9F%E8%83%BD%E9%80%BB%E8%BE%91%E6%9E%81%E4%BB%A3%E7%A0%81"><span class="toc-text">功能逻辑极代码</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%BA%95%E9%83%A8tab%E8%8F%9C%E5%8D%95"><span class="toc-text">底部tab菜单</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%AC%E5%85%B1%E7%9A%84%E5%A4%B4%E9%83%A8"><span class="toc-text">公共的头部</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Layout%E5%B8%83%E5%B1%80"><span class="toc-text">Layout布局</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%A6%96%E9%A1%B5%E7%9A%84%E8%BD%AE%E6%92%AD%E5%9B%BE-%E5%8F%8A-%E7%B2%BE%E5%93%81%E5%A5%BD%E8%8F%9C"><span class="toc-text">首页的轮播图 及 精品好菜</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%86%E7%B1%BB%E9%A1%B5%E9%9D%A2"><span class="toc-text">分类页面</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%BE%8E%E9%A3%9F%E5%9C%B0%E5%9B%BE"><span class="toc-text">美食地图</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9B%B4%E8%BF%87%E8%8F%9C%E5%8D%95-%E5%88%87%E6%8D%A2tab%E5%9C%B0%E5%9B%BE%E7%9A%84%E6%98%BE%E9%9A%90"><span class="toc-text">更过菜单 切换tab地图的显隐</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2021/04/16/gin-vue-admin/" title="Gin-Vue-Admin"><img src="/img/gin-vue-admin.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Gin-Vue-Admin"/></a><div class="content"><a class="title" href="/2021/04/16/gin-vue-admin/" title="Gin-Vue-Admin">Gin-Vue-Admin</a><time datetime="2021-04-15T16:00:00.000Z" title="发表于 2021-04-16 00:00:00">2021-04-16</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/01/08/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E7%BB%84%E4%BB%B6%E7%9A%84%E6%B8%B2%E6%9F%9310/" title="Vue源码开发-组件的渲染10"><img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2018-07-17%2F3eca5394963b50e37b7be2ba320029ec%2F00003.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&amp;refer=http%3A%2F%2Fpic.vjshi.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530644&amp;t=10679b5732c52e39eeb588040240a790" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Vue源码开发-组件的渲染10"/></a><div class="content"><a class="title" href="/2021/01/08/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E7%BB%84%E4%BB%B6%E7%9A%84%E6%B8%B2%E6%9F%9310/" title="Vue源码开发-组件的渲染10">Vue源码开发-组件的渲染10</a><time datetime="2021-01-07T16:00:00.000Z" title="发表于 2021-01-08 00:00:00">2021-01-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/01/07/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E7%BB%84%E4%BB%B6%E7%9A%84%E5%90%88%E5%B9%B6%E7%AD%96%E7%95%A509/" title="Vue源码开发-组件合并策略09"><img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcz-video-photo.oss-cn-beijing.aliyuncs.com%2F20191017%2F4cfc341591d242327b67e9ceb6953612_00002.jpg&amp;refer=http%3A%2F%2Fcz-video-photo.oss-cn-beijing.aliyuncs.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530702&amp;t=80943e12d5239f63beafd6d1c540855f" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Vue源码开发-组件合并策略09"/></a><div class="content"><a class="title" href="/2021/01/07/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E7%BB%84%E4%BB%B6%E7%9A%84%E5%90%88%E5%B9%B6%E7%AD%96%E7%95%A509/" title="Vue源码开发-组件合并策略09">Vue源码开发-组件合并策略09</a><time datetime="2021-01-06T16:00:00.000Z" title="发表于 2021-01-07 00:00:00">2021-01-07</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/01/06/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E6%95%B0%E7%BB%84%E7%9A%84%E4%BE%9D%E8%B5%96%E6%94%B6%E9%9B%8608/" title="Vue源码开发-数组的依赖收集08"><img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2018-07-17%2F3eca5394963b50e37b7be2ba320029ec%2F00003.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&amp;refer=http%3A%2F%2Fpic.vjshi.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530644&amp;t=10679b5732c52e39eeb588040240a790" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Vue源码开发-数组的依赖收集08"/></a><div class="content"><a class="title" href="/2021/01/06/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E6%95%B0%E7%BB%84%E7%9A%84%E4%BE%9D%E8%B5%96%E6%94%B6%E9%9B%8608/" title="Vue源码开发-数组的依赖收集08">Vue源码开发-数组的依赖收集08</a><time datetime="2021-01-05T16:00:00.000Z" title="发表于 2021-01-06 00:00:00">2021-01-06</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/01/06/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E5%90%88%E5%B9%B607/" title="Vue源码开发-生命周期合并07"><img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2018-07-17%2Faf41dabad727ba80c9ca8a2bfbd22a58%2F00004.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&amp;refer=http%3A%2F%2Fpic.vjshi.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530659&amp;t=bbcfe1e86f393eecbb0722db1b92e475" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Vue源码开发-生命周期合并07"/></a><div class="content"><a class="title" href="/2021/01/06/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E5%90%88%E5%B9%B607/" title="Vue源码开发-生命周期合并07">Vue源码开发-生命周期合并07</a><time datetime="2021-01-05T16:00:00.000Z" title="发表于 2021-01-06 00:00:00">2021-01-06</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright"><span>&copy;2017 - 2021</span><svg style="width:2em; height:2em;position: relative;top: 10px;" aria-hidden="true"><use xlink:href="#icon-Butterfly"></use></svg><span>北城韩雨</span></div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text"><p><a style="margin-inline:5px" target="_blank" href="https://hexo.io/"><img src="https://img.shields.io/badge/Frame-Hexo-blue?style=flat&logo=hexo" title="博客框架为Hexo"></a><a style="margin-inline:5px" target="_blank" href="https://butterfly.js.org/"><img src="https://img.shields.io/badge/Theme-Butterfly-6513df?style=flat&logo=bitdefender" title="主题采用butterfly"></a><a style="margin-inline:5px" target="_blank" href="https://www.jsdelivr.com/"><img src="https://img.shields.io/badge/CDN-jsDelivr-orange?style=flat&logo=jsDelivr" title="本站使用JsDelivr为静态资源提供CDN加速"></a></p></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/medium-zoom/dist/medium-zoom.min.js"></script><div class="js-pjax"></div><script defer src="/live2d-widget/autoload.js"></script><script src="/js/coin.js"></script><script async src="//at.alicdn.com/t/font_2700632_3rtvhzzpl3h.js"></script><script src="/js/liuxing.js" data-pjax></script><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start --><div class="js-pjax"><script async="async">var arr = document.getElementsByClassName('recent-post-item');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '1s');
    arr[i].setAttribute('data-wow-delay', '0ms');
    arr[i].setAttribute('data-wow-offset', '100');
    arr[i].setAttribute('data-wow-iteration', '1');
  }</script><script async="async">var arr = document.getElementsByClassName('card-widget');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script></div><script defer src="https://cdn.jsdelivr.net/gh/graingert/wow@1.3.0/dist/wow.min.js"></script><script defer src="https://cdn.jsdelivr.net/npm/hexo-butterfly-wowjs/lib/wow_init.min.js"></script><script async src="//at.alicdn.com/t/font_2032782_8d5kxvn09md.js"></script><!-- hexo injector body_end end --></body></html>